<template>
	<view>
		<!-- 		<view class="container" style="font-size: 28px;">

			<uni-nav-bar shadow left-icon="left" @clickLeft="back" leftText="返回" rightText="" title="住院充值"
				@clickRight="right()" />
		
		</view> -->
		<view class="flex-col zhuyuanchongzhi">

			<view class="flex-col wrapper">
				<u-form-item class="formItemInput" label="住院人" :label-width="120">
					<u-input placeholder="请输入内容" v-model="eVo.name" type="text"></u-input>
				</u-form-item>
				<u-form-item class="formItemInput-two" label="就诊卡号" :label-width="120">
					<u-input placeholder="请输入内容" v-model="eVo.hospitalNumber" type="text"></u-input>
				</u-form-item>
			</view>
			<view class="flex-row wrapper-two">
				<view class="u-line-1 text">住院余额</view>
				<view class="u-line-1 text">￥{{patientCard.balance}}</view>
				<view class="u-line-1 text-two">住院余额</view>
			</view>
			<view class="u-line-1 text-three">在线充值</view>
			<view class="flex-row wrapper-three">
				<u-button class="b1" size="medium" shape="circle" :ripple="true" :hairLine="false" @click="butt(500)">
					500
				</u-button>
				<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(1000)">
					1000
				</u-button>
				<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(2000)">
					2000
				</u-button>
			</view>
			<view class="flex-row wrapper-three">
				<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(5000)">
					5000
				</u-button>
				<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(10000)">
					10000
				</u-button>
				
			<!-- 	<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(10000)">
					自定义
				</u-button> -->
				
<!-- 				<view>
				<u-button class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butt(5)">
					自定义
				</u-button>
				</view> -->
				<view v-if="loading == false">
				<u-button  class="button-five" size="medium" shape="circle" :ripple="true" :hairLine="false"
					@click="butts()">
					自定义
				</u-button>
				</view>
				
				
				<view v-if="loading == true">
				<view style="width: 110px;height: 50px;background-color: #fff;">
					<template> 
						<u--input v-model="ms"  placeholder="请输入金额"  border="surround" clearable="true" type="number"></u--input>
					</template>
				</view>
				</view>
				
				
				
				
				
			
			</view>
			<view class="u-line-1 text-four">充值记录</view>
	<!-- 		<u-button class="button-seven" shape="circle" @click="onclick()">
				确认充值
			</u-button> -->
			<u-button class="button-seven" shape="circle" @tap="$refs.passInput.open()">
				确认充值
			</u-button>
		</view>


		<view>
			<lyy-pass-input ref="passInput" title="住院充值" :money="m" @confirm="confirm" @close="close">
				<template slot="extend">
					<view class="extend">
						<!--   <view class="extend-title">
                        服务费
                    </view>
                    <view class="">
                        ￥1.00
                    </view> -->
					</view>
					<view class="extend">
						<!-- <view class="extend-title">
                        费率
                    </view>
                    <view class="">
                        0.10%
                    </view> -->
					</view>
				</template>
			</lyy-pass-input>
		</view>


	</view>


</template>


<script>
	export default {

		data() {
			return {
				form: {
					username: "",
				},
				eVo: {

					money: null
				},
				m: 0,
				ms: 0,
				patientCard: {
					balance: 100
				},
				loading:false

			}
		},
		onLoad(res) {
			this.eVo = JSON.parse(decodeURIComponent(res.eVo))
			// console.log("evo::::::" + this.eVo)
			// console.log("evo::::::" + this.eVo.patientId)
			// console.log("evo::::::" + this.eVo.hospitalNumber)

			this.find()


		},
		


		methods: {


			find() {
				uni.request({
					url: "http://localhost:9000/user/user/patient-card/getBlaceByhospitalNumber/" + this.eVo.hospitalNumber,
					method: "get",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.patientCard = res.data.data.patientCard
							// console.log(res.data.data.patientCard.balance)
							// console.log(res.data.data.patientCard)
						}
					}
				})
			},


			confirm(e) {
				if (e.pass == '123456') {

					this.onclick()
					this.find()
					this.$refs.passInput.close()
					

				} else {
					
					console.log("密码错误")
					this.$refs.passInput.clear()

				}
				console.log(e)
			},
			close() {
				console.log('close')
			},




			onclick() {
				
				// var b =this.c 
				if(this.ms != '0'){
					console.log("金钱传递")
					this.m = this.ms
				}
				
				
				this.eVo.money = this.m
				this.eVo.rechargeExplain = '住院充值'
				uni.request({
					url: "http://localhost:9000/user/user/patient-card/pay",
					method: "post",
					data: this.eVo,
					success: (res) => {
						console.log(res)
						if (res.data.code == 20000) {
							this.record_id = res.data.data.record_id
							console.log(res.data.data.message)
							console.log(res.data.data.record_id)
							uni.navigateTo({
								url: "./particulars?payId=" + this.record_id,
								// url: "./details?id=" + e.id,
							})
						}
					}
				})

			},


			butt(i) {
				this.m = i
				// console.log("按钮的值：：：" + this.m)
				// console.log("按钮的值：：：" + this.patientCard.balance)

			},
			butts() {
				this.loading = true
				
				// console.log("按钮的值：：：" + this.m)
				// console.log("按钮的值：：：" + this.patientCard.balance)
			
			}

		}
	}
</script>

<style lang="scss" scoped>
	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.zhuyuanchongzhi {
		height: 896px;
		padding: 35px 0px 0px 22px;

		.wrapper {
			width: 366px;
			margin-bottom: 42px;
			padding: 16px 0px 15px 14px;
			background: rgba(255, 255, 255, 1);

			.formItemInput {
				width: 340px;
				margin: 0px 0px 5px 1px;
			}

			.formItemInput-two {
				width: 342px;
			}
		}

		.wrapper-two {
			width: 366px;
			height: 51px;
			background: rgba(255, 255, 255, 1);
			justify-content: space-between;
			margin-bottom: 22px;
			padding: 11px 3px 0px 8px;

			.text {
				width: 111px;
				font-size: 20px;
			}

			.text-two {
				width: 111px;
				top: -223916px;
				left: -22525px;
				font-size: 22px;
				position: absolute;
			}
		}

		.text-three {
			width: 111px;
			margin-bottom: 28px;
			font-size: 22px;
		}

		.wrapper-three {
			width: 353.5px;
			justify-content: space-between;
			margin: 0px 0px 24px 16px;
			padding-right: 0.5px;

			.button {
				background: rgba(242, 242, 242, 1);
			}

			.button-two {
				width: 108px;
				background: rgba(242, 242, 242, 1);
			}

			.button-three {
				width: 111px;
				background: rgba(242, 242, 242, 1);
			}
		}

		.wrapper-four {
			width: 359.5px;
			justify-content: space-between;
			margin: 0px 0px 31px 13px;

			.button-four {
				width: 111px;
				background: rgba(242, 242, 242, 1);
			}

			.button-five {
				width: 105px;
				background: rgba(242, 242, 242, 1);
			}

			.button-five :focus {
				background: red;
			}

			.button-six {
				width: 111px;
				background: rgba(242, 242, 242, 1);
			}
		}

		.text-four {
			width: 80px;
			margin: 0px 0px 23px 303px;
			color: rgba(69, 149, 255, 1);
		}

		.button-seven {
			width: 326px;
			margin: 0.5px 0px 0px 22px;
			background: rgba(0, 110, 255, 1);
			color: rgba(255, 255, 255, 1);
		}
	}
</style>
